package com.study.rabbitmq.advance.exchange;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class ExchangType {
	public static void main(String[] args) {
		ConnectionFactory factory = new ConnectionFactory();
		factory.setHost("192.168.20.68");
		factory.setPort(5672);
		factory.setUsername("leke");
		factory.setPassword("leke@@@");
//		Connection connection = factory.newConnection();
//		Channel channel = connection.createChannel();
//		String queueName = "queue";
//		String exchangeName = "exchange";

//		channel.exchangeDeclare(exchangeName, BuiltinExchangeType.FANOUT);
//		channel.queueDeclare(queueName,false,false,null);
//		channel.queueBind(queueName, exchangeName, "routingKey");

		//与路由分发相关的属性
		//exchange :name,type
		//binding:source, destination, routing_key(bindingKey: 正则表达式 )
		//queue:name

		//创建exchange : exchange name, exchange type
		//创建queue : queue name
		//绑定exchange与queue :queue name, exchange name, routingKey(bindingKey)。
		// 若queue不进行绑定，会默认绑定到Default exchange, exchange name = "", bindingKey = queue name;
		//发送消息 : queue name, exchange name, routingKey

		//通过根据exchange name, routingKey找到所有的 binding.
		// (如果exchange 是fanout的, 忽略routingKey; 如果exchange 是topic的，routingKey要进行模糊匹配)
		//如果exchange type :fanout, 发送给所有queue
		//如果type :direct, 判断哪一个binding key与routing key相同
		//如果type :topic , routing key 与binding key进行模糊匹配
	}
}
